#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-12-21 9:28 上午
# @Author  : yangdy
# @File    : 2020-12-21.746.使用最小花费爬楼梯
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def minCostClimbingStairs(self, cost: List[int]) -> int:
        dp = [cost[0], cost[1]]
        for i in range(2, len(cost)):
            dp.append(min(dp[-1], dp[-2]) + cost[i])
        return min(dp[-1], dp[-2])


questions = [
    ([10, 15, 20],),
    ([1, 100, 1, 1, 1, 100, 1, 1, 100, 1],),
    ([0, 0, 0, 1],),
]

work(questions, lambda q: Solution().minCostClimbingStairs(q[0]))
